package com.sakura.thread.chapter1.test6;

/**
 * Created by apple on 2018/12/10.
 */
public class YieldTest implements Runnable{

    YieldTest(){
        Thread t = new Thread(this);
        t.start();
    }
    @Override
    public void run() {
        for(int i = 0;i< 5;i++){
            if(i%5 == 0){
                System.out.println(Thread.currentThread()+"yield cpu ..."+i);
                Thread.yield();
            }
        }

        System.out.println(Thread.currentThread()+" is over");
    }

    public static void main(String[] args) {
        new YieldTest();
        new YieldTest();
        new YieldTest();
    }
}
